/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: DriverInformationServiceImpl
 * Author:   李毅
 * Date:     2019/10/18 11:59
 * Description: 司机信息业务实现类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.ymtms.supplycar.service.impl;

import com.ymtms.supplycar.dao.DriverInformationMapper;
import com.ymtms.supplycar.exception.CarException;
import com.ymtms.supplycar.pojo.DriverInformation;
import com.ymtms.supplycar.service.DriverInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 〈一句话功能简述〉<br> 
 * 〈司机信息业务实现类〉
 *
 * @author 李毅
 * @create 2019/10/18
 * @since 1.0.0
 */
@Service
public class DriverInformationServiceImpl implements DriverInformationService {

    @Autowired
    private DriverInformationMapper driverInformationMapper;

    @Override
    public DriverInformation findDriver(BigDecimal weight, BigDecimal volume) {
        DriverInformation driver = driverInformationMapper.selectByvolumeAndWeight(weight, volume);
        if (driver==null){
            throw new CarException("查询司机失败！，请重试!");
        }
        return driver;
    }

    @Override
    public DriverInformation getDriver(Integer driverPkid) {
        DriverInformation driverInformation = driverInformationMapper.selectByPrimaryKey(driverPkid);
        if (driverInformation == null){
            throw new CarException("查询司机失败！，请重试!");
        }
        return driverInformation;
    }
}